package com.bmit.ma.controller;

import com.bmit.ma.model.Manager;
import com.bmit.ma.service.IManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ManagerController {
    @Autowired
    private IManagerService service;

    @RequestMapping("create")
    public boolean create(@RequestParam String id, @RequestParam String name, @RequestParam String password) {
        return service.insert(id, name, password);
    }

    @RequestMapping("query")
    public Manager query(@RequestParam String id, @RequestParam String name) {
        return service.selectOne(id, name);
    }

    @RequestMapping("delete")
    public boolean delete(@RequestParam String id, @RequestParam String name) {
        return service.delete(id, name);
    }

    @RequestMapping("update")
    public boolean update(@RequestParam String id, @RequestParam String name, @RequestParam String password) {
        return service.update(id, name, password);
    }

    @RequestMapping("all")
    public List<Manager> queryAll() {
        return service.selectAll();
    }


}
